/**
 * Copyright (c) 2016-2021 by the respective copyright holders.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */
package com.zsmartsystems.zigbee.zcl.clusters.demandresponseandloadcontrol;

import java.util.Calendar;

import javax.annotation.Generated;

import com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer;
import com.zsmartsystems.zigbee.zcl.ZclFieldSerializer;
import com.zsmartsystems.zigbee.zcl.protocol.ZclCommandDirection;
import com.zsmartsystems.zigbee.zcl.protocol.ZclDataType;

/**
 * Cancel Load Control Event value object class.
 * <p>
 * Cluster: <b>Demand Response And Load Control</b>. Command ID 0x01 is sent <b>FROM</b> the server.
 * This command is a <b>specific</b> command used for the Demand Response And Load Control cluster.
 * <p>
 * Code is auto-generated. Modifications may be overwritten!
 */
@Generated(value = "com.zsmartsystems.zigbee.autocode.ZigBeeCodeGenerator", date = "2020-12-25T10:11:19Z")
public class CancelLoadControlEvent extends ZclDemandResponseAndLoadControlCommand {
    /**
     * The cluster ID to which this command belongs.
     */
    public static int CLUSTER_ID = 0x0701;

    /**
     * The command ID.
     */
    public static int COMMAND_ID = 0x01;

    /**
     * Issuer Event ID command message field.
     * <p>
     * Unique identifier generated by the Energy provider. The value of this field allows
     * matching of Event reports with a specific Demand Response and Load Control event. It's
     * expected the value contained in this field is a unique number managed by upstream
     * systems or a UTC based time stamp (UTCTime data type) identifying when the Load Control
     * Event was issued.
     */
    private Integer issuerEventId;

    /**
     * Device Class command message field.
     * <p>
     * Bit encoded field representing the Device Class to apply the current Load Control
     * Event. Each bit, if set individually or in combination, indicates the class device(s)
     * needing to participate in the event. (Note that the participating device may be
     * different than the controlling device. For instance, a thermostat may act on behalf of
     * an HVAC compressor or furnace and/or Strip Heat/Baseboard Heater and should take
     * action on their behalf, as the thermostat itself is not subject to load shed but controls
     * devices that are subject to load shed.)
     */
    private Integer deviceClass;

    /**
     * Utility Enrollment Group command message field.
     * <p>
     * The Utility Enrollment Group field can be used in conjunction with the Device Class
     * bits. It provides a mechanism to direct Load Control Events to groups of Devices.
     * Example, by assigning two different groups relating to either Demand Response
     * programs or geographic areas, Load Control Events can be further directed for a subset
     * of Device Classes (i.e. Device Class Bit 0 and Utility Enrollment Group #1 vs. Device
     * Class Bit0 and Utility Enrollment Group #2). 0x00 addresses all groups, and values 0x01
     * to 0xFF address individual groups that match. Please refer to sub-clause D.2.3.2.1 for
     * further details.
     */
    private Integer utilityEnrollmentGroup;

    /**
     * Cancel Control command message field.
     */
    private Integer cancelControl;

    /**
     * Effective Time command message field.
     * <p>
     *
     * <p>
     * <b>Note:</b> This field is deprecated; a Cancel Load Control command shall now take immediate
     * effect. A value of 0x00000000 shall be used in all Cancel Load Control commands
     * <p>
     * UTC Timestamp representing when the cancelling of the event is scheduled to start. An
     * effective time of 0x00000000 is a special time denoting “now.” If the device would send
     * an event with an Effective Time of now, adjust the Duration In Minutes field to
     * correspond to the remainder of the event.
     */
    private Calendar effectiveTime;

    /**
     * Default constructor.
     *
     * @deprecated from release 1.3.0. Use the parameterised constructor instead of the default constructor and setters.
     */
    @Deprecated
    public CancelLoadControlEvent() {
        clusterId = CLUSTER_ID;
        commandId = COMMAND_ID;
        genericCommand = false;
        commandDirection = ZclCommandDirection.SERVER_TO_CLIENT;
    }

    /**
     * Constructor providing all required parameters.
     *
     * @param issuerEventId {@link Integer} Issuer Event ID
     * @param deviceClass {@link Integer} Device Class
     * @param utilityEnrollmentGroup {@link Integer} Utility Enrollment Group
     * @param cancelControl {@link Integer} Cancel Control
     * @param effectiveTime {@link Calendar} Effective Time
     */
    public CancelLoadControlEvent(
            Integer issuerEventId,
            Integer deviceClass,
            Integer utilityEnrollmentGroup,
            Integer cancelControl,
            Calendar effectiveTime) {

        clusterId = CLUSTER_ID;
        commandId = COMMAND_ID;
        genericCommand = false;
        commandDirection = ZclCommandDirection.SERVER_TO_CLIENT;

        this.issuerEventId = issuerEventId;
        this.deviceClass = deviceClass;
        this.utilityEnrollmentGroup = utilityEnrollmentGroup;
        this.cancelControl = cancelControl;
        this.effectiveTime = effectiveTime;
    }

    /**
     * Gets Issuer Event ID.
     * <p>
     * Unique identifier generated by the Energy provider. The value of this field allows
     * matching of Event reports with a specific Demand Response and Load Control event. It's
     * expected the value contained in this field is a unique number managed by upstream
     * systems or a UTC based time stamp (UTCTime data type) identifying when the Load Control
     * Event was issued.
     *
     * @return the Issuer Event ID
     */
    public Integer getIssuerEventId() {
        return issuerEventId;
    }

    /**
     * Sets Issuer Event ID.
     * <p>
     * Unique identifier generated by the Energy provider. The value of this field allows
     * matching of Event reports with a specific Demand Response and Load Control event. It's
     * expected the value contained in this field is a unique number managed by upstream
     * systems or a UTC based time stamp (UTCTime data type) identifying when the Load Control
     * Event was issued.
     *
     * @param issuerEventId the Issuer Event ID
     * @deprecated as of 1.3.0. Use the parameterised constructor instead to ensure that all mandatory fields are provided.
     */
    @Deprecated
    public void setIssuerEventId(final Integer issuerEventId) {
        this.issuerEventId = issuerEventId;
    }

    /**
     * Gets Device Class.
     * <p>
     * Bit encoded field representing the Device Class to apply the current Load Control
     * Event. Each bit, if set individually or in combination, indicates the class device(s)
     * needing to participate in the event. (Note that the participating device may be
     * different than the controlling device. For instance, a thermostat may act on behalf of
     * an HVAC compressor or furnace and/or Strip Heat/Baseboard Heater and should take
     * action on their behalf, as the thermostat itself is not subject to load shed but controls
     * devices that are subject to load shed.)
     *
     * @return the Device Class
     */
    public Integer getDeviceClass() {
        return deviceClass;
    }

    /**
     * Sets Device Class.
     * <p>
     * Bit encoded field representing the Device Class to apply the current Load Control
     * Event. Each bit, if set individually or in combination, indicates the class device(s)
     * needing to participate in the event. (Note that the participating device may be
     * different than the controlling device. For instance, a thermostat may act on behalf of
     * an HVAC compressor or furnace and/or Strip Heat/Baseboard Heater and should take
     * action on their behalf, as the thermostat itself is not subject to load shed but controls
     * devices that are subject to load shed.)
     *
     * @param deviceClass the Device Class
     * @deprecated as of 1.3.0. Use the parameterised constructor instead to ensure that all mandatory fields are provided.
     */
    @Deprecated
    public void setDeviceClass(final Integer deviceClass) {
        this.deviceClass = deviceClass;
    }

    /**
     * Gets Utility Enrollment Group.
     * <p>
     * The Utility Enrollment Group field can be used in conjunction with the Device Class
     * bits. It provides a mechanism to direct Load Control Events to groups of Devices.
     * Example, by assigning two different groups relating to either Demand Response
     * programs or geographic areas, Load Control Events can be further directed for a subset
     * of Device Classes (i.e. Device Class Bit 0 and Utility Enrollment Group #1 vs. Device
     * Class Bit0 and Utility Enrollment Group #2). 0x00 addresses all groups, and values 0x01
     * to 0xFF address individual groups that match. Please refer to sub-clause D.2.3.2.1 for
     * further details.
     *
     * @return the Utility Enrollment Group
     */
    public Integer getUtilityEnrollmentGroup() {
        return utilityEnrollmentGroup;
    }

    /**
     * Sets Utility Enrollment Group.
     * <p>
     * The Utility Enrollment Group field can be used in conjunction with the Device Class
     * bits. It provides a mechanism to direct Load Control Events to groups of Devices.
     * Example, by assigning two different groups relating to either Demand Response
     * programs or geographic areas, Load Control Events can be further directed for a subset
     * of Device Classes (i.e. Device Class Bit 0 and Utility Enrollment Group #1 vs. Device
     * Class Bit0 and Utility Enrollment Group #2). 0x00 addresses all groups, and values 0x01
     * to 0xFF address individual groups that match. Please refer to sub-clause D.2.3.2.1 for
     * further details.
     *
     * @param utilityEnrollmentGroup the Utility Enrollment Group
     * @deprecated as of 1.3.0. Use the parameterised constructor instead to ensure that all mandatory fields are provided.
     */
    @Deprecated
    public void setUtilityEnrollmentGroup(final Integer utilityEnrollmentGroup) {
        this.utilityEnrollmentGroup = utilityEnrollmentGroup;
    }

    /**
     * Gets Cancel Control.
     *
     * @return the Cancel Control
     */
    public Integer getCancelControl() {
        return cancelControl;
    }

    /**
     * Sets Cancel Control.
     *
     * @param cancelControl the Cancel Control
     * @deprecated as of 1.3.0. Use the parameterised constructor instead to ensure that all mandatory fields are provided.
     */
    @Deprecated
    public void setCancelControl(final Integer cancelControl) {
        this.cancelControl = cancelControl;
    }

    /**
     * Gets Effective Time.
     * <p>
     *
     * <p>
     * <b>Note:</b> This field is deprecated; a Cancel Load Control command shall now take immediate
     * effect. A value of 0x00000000 shall be used in all Cancel Load Control commands
     * <p>
     * UTC Timestamp representing when the cancelling of the event is scheduled to start. An
     * effective time of 0x00000000 is a special time denoting “now.” If the device would send
     * an event with an Effective Time of now, adjust the Duration In Minutes field to
     * correspond to the remainder of the event.
     *
     * @return the Effective Time
     */
    public Calendar getEffectiveTime() {
        return effectiveTime;
    }

    /**
     * Sets Effective Time.
     * <p>
     *
     * <p>
     * <b>Note:</b> This field is deprecated; a Cancel Load Control command shall now take immediate
     * effect. A value of 0x00000000 shall be used in all Cancel Load Control commands
     * <p>
     * UTC Timestamp representing when the cancelling of the event is scheduled to start. An
     * effective time of 0x00000000 is a special time denoting “now.” If the device would send
     * an event with an Effective Time of now, adjust the Duration In Minutes field to
     * correspond to the remainder of the event.
     *
     * @param effectiveTime the Effective Time
     * @deprecated as of 1.3.0. Use the parameterised constructor instead to ensure that all mandatory fields are provided.
     */
    @Deprecated
    public void setEffectiveTime(final Calendar effectiveTime) {
        this.effectiveTime = effectiveTime;
    }

    @Override
    public void serialize(final ZclFieldSerializer serializer) {
        serializer.serialize(issuerEventId, ZclDataType.UNSIGNED_32_BIT_INTEGER);
        serializer.serialize(deviceClass, ZclDataType.BITMAP_16_BIT);
        serializer.serialize(utilityEnrollmentGroup, ZclDataType.UNSIGNED_8_BIT_INTEGER);
        serializer.serialize(cancelControl, ZclDataType.BITMAP_8_BIT);
        serializer.serialize(effectiveTime, ZclDataType.UTCTIME);
    }

    @Override
    public void deserialize(final ZclFieldDeserializer deserializer) {
        issuerEventId = (Integer) deserializer.deserialize(ZclDataType.UNSIGNED_32_BIT_INTEGER);
        deviceClass = (Integer) deserializer.deserialize(ZclDataType.BITMAP_16_BIT);
        utilityEnrollmentGroup = (Integer) deserializer.deserialize(ZclDataType.UNSIGNED_8_BIT_INTEGER);
        cancelControl = (Integer) deserializer.deserialize(ZclDataType.BITMAP_8_BIT);
        effectiveTime = (Calendar) deserializer.deserialize(ZclDataType.UTCTIME);
    }

    @Override
    public String toString() {
        final StringBuilder builder = new StringBuilder(197);
        builder.append("CancelLoadControlEvent [");
        builder.append(super.toString());
        builder.append(", issuerEventId=");
        builder.append(issuerEventId);
        builder.append(", deviceClass=");
        builder.append(deviceClass);
        builder.append(", utilityEnrollmentGroup=");
        builder.append(utilityEnrollmentGroup);
        builder.append(", cancelControl=");
        builder.append(cancelControl);
        builder.append(", effectiveTime=");
        builder.append(effectiveTime);
        builder.append(']');
        return builder.toString();
    }

}
